# # url = 'https://vip.xiniudata.com/api/vip/library/v3/init' post
#
# import os
# os.environ["EXECJS_RUNTIME"] = "Node"
# os.environ["NODE_EXE"] = r"D:\Node.js\node.exe"
# import requests
# import execjs
#
#
#
# with open('./parse/烯牛数据.js', 'r', encoding='utf-8') as f:
#     js_str = f.read()
#     js_code = execjs.compile(js_str, cwd="./parse")
#
#
# payload = {
#     "libraryId": 33,
#     "sectionId": 208,
#     "filterConfigIds": [
#         271,
#         269,
#         270,
#         1404,
#         889,
#         305,
#         272,
#         266,
#         1825,
#         267,
#         268,
#         1162
#     ],
#     "queryParam": {
#         "start": 0,
#         "limit": 20,
#         "searchFieldIds": None,
#         "is_oversea": [
#             "1",
#             "2",
#             "3",
#             "4"
#         ],
#         "query_field_ids": None
#     }
# }
# json_data = js_code.call("getJsonData", payload)
# res = requests.post("https://vip.xiniudata.com/api/vip/library/v3/init")
#
# # d = res.json()['d']
# d = res.json()
# print(d)
#
# data = js_code.call("parse_d", d)
# print(data)
#
# # 请求加密  payload 自定义  sign md5
# # 响应解密   d 自定义


import requests
import execjs


res = requests.post('https://vip.xiniudata.com/api/vip/web/login/login_by_password', json={

    "payload": {
        "account": "18236602708",
        "password": "qikuedu123"
    },
    "v": -20180620

})

print(res.cookies)


with open("./parse/烯牛数据.js", "r", encoding="utf-8") as f:
    js_str = f.read()
    js_code = execjs.compile(js_str, cwd="./parse")
# d.payload = payload
payload = {
    "libraryId": 33,
    "sectionId": 208,
    "filterConfigIds": [
        271,
        269,
        270,
        1404,
        889,
        305,
        272,
        266,
        1825,
        267,
        268,
        1162
    ],
    "queryParam": {
        "start": 0,
        "limit": 20,
        "searchFieldIds": None,
        "is_oversea": [
            "1",
            "2",
            "3",
            "4"
        ],
        "query_field_ids": None
    }
}

json_data = js_code.call("getJsonData", payload)


res = requests.post('https://vip.xiniudata.com/api/vip/library/v3/init', json=json_data, cookies=res.cookies)

d = res.json()['d']


data = js_code.call("parse_d", d)
print(data)




# 请求加密  payload 自定义  sign md5
# 响应解密   d 自定义